package SQL;

import java.sql.*;

/**
 * 数据库链接
 */
public class SQL_Collection {

    public static Connection Collection () throws SQLException {
        //1.加载驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        //2.用户信息和 url
        // ？（用问号连接参数）useUnicode = true (支持中文编码)& characterEncoding = utf8（设定中文字符集为utf8） & useSSL = true（使用安全的连接）
        String url = "jdbc:mysql://localhost:3306/freshmaninfo? useUnicode = true & characterEncoding = utf8 & useSSL = true";
        String username = "root";
        String password = "123456";

//        connection.close();
        return  DriverManager.getConnection(url,username,password);

    }
}